//
//  ZHPhotoBrowser.h
//  ZHPhotoBrowser
//
//  Created by Michael Waterfall on 14/10/2010.
//  Copyright 2010 d3i. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "ZHMWPhoto.h"
#import "ZHMWPhotoProtocol.h"
#import "ZHMWCaptionView.h"

// Debug Logging
#if 0 // Set to 1 to enable debug logging
#define MWLog(x, ...) NSLog(x, ## __VA_ARGS__);
#else
#define MWLog(x, ...)
#endif

@class ZHPhotoBrowser;

@protocol ZHPhotoBrowserDelegate <NSObject>

- (NSUInteger)numberOfPhotosInPhotoBrowser:(ZHPhotoBrowser *)photoBrowser;
- (id <ZHMWPhoto>)photoBrowser:(ZHPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index;

@optional

- (id <ZHMWPhoto>)photoBrowser:(ZHPhotoBrowser *)photoBrowser thumbPhotoAtIndex:(NSUInteger)index;
- (ZHMWCaptionView *)photoBrowser:(ZHPhotoBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index;
- (NSString *)photoBrowser:(ZHPhotoBrowser *)photoBrowser titleForPhotoAtIndex:(NSUInteger)index;
- (void)photoBrowser:(ZHPhotoBrowser *)photoBrowser didDisplayPhotoAtIndex:(NSUInteger)index;
- (void)photoBrowser:(ZHPhotoBrowser *)photoBrowser actionButtonPressedForPhotoAtIndex:(NSUInteger)index;
- (BOOL)photoBrowser:(ZHPhotoBrowser *)photoBrowser isPhotoSelectedAtIndex:(NSUInteger)index;
- (void)photoBrowser:(ZHPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index selectedChanged:(BOOL)selected;
- (void)photoBrowserDidFinishModalPresentation:(ZHPhotoBrowser *)photoBrowser;

/**
  删除某个照片
 
 @param photoBrowser photoBrowser description
 @param index index description
 @return 是否可以删除
 */
- (BOOL )photoBrowser:(ZHPhotoBrowser *)photoBrowser deletedPhoto:(NSUInteger )index;

// custom
// 用户主动分享
- (void)photoBrowser:(ZHPhotoBrowser *)photoBrowser didSharePhotoAtIndex:(NSUInteger)index;

@end

@interface ZHPhotoBrowser : UIViewController <UIScrollViewDelegate, UIActionSheetDelegate>

@property (nonatomic, weak) IBOutlet id<ZHPhotoBrowserDelegate> delegate;
@property (nonatomic) BOOL zoomPhotosToFill;
@property (nonatomic) BOOL displayActionButton;
@property (nonatomic) BOOL displaySelectionButtons;
@property (nonatomic) BOOL alwaysShowControls;
@property (nonatomic) BOOL enableGrid;
@property (nonatomic) BOOL enableSwipeToDismiss;
@property (nonatomic) BOOL startOnGrid;
@property (nonatomic) BOOL autoPlayOnAppear;
/** 延迟x秒隐藏元素,默认5s,0表示不自动隐藏 */
@property (nonatomic, assign) NSUInteger delayToHideElements;
/** 固定导航栏，默认NO,不固定,跟随 delayToHideElements 隐藏 */
@property (nonatomic, assign) BOOL fixedNavbar;
/** 标题颜色，默认 白色 */
@property (nonatomic, strong) UIColor *titleColor;
/** 导航栏back 图片 */
@property (nonatomic, strong) UIImage *navBackImg;
/** 导航栏是否显示删除按钮,默认NO */
@property (nonatomic, assign) BOOL showNavDelete;
@property (nonatomic, readonly) NSUInteger currentIndex;

// Customise image selection icons as they are the only icons with a colour tint
// Icon should be located in the app's main bundle
@property (nonatomic, strong) NSString *customImageSelectedIconName;
@property (nonatomic, strong) NSString *customImageSelectedSmallIconName;

// custom
// 使用多行标题 和ZHMWPhoto.time 绑定
@property (nonatomic) BOOL useMutilRowTitle;
// 显示工具栏
@property (nonatomic) BOOL displayToolView;

@property (nonatomic, strong) UIImage *imageFromView;

// Init
- (id)initWithPhotos:(NSArray *)photosArray;
- (id)initWithDelegate:(id <ZHPhotoBrowserDelegate>)delegate;

// Reloads the photo browser and refetches data
- (void)reloadData;

// Set page that photo browser starts on
- (void)setCurrentPhotoIndex:(NSUInteger)index;

// Navigation
- (void)showNextPhotoAnimated:(BOOL)animated;
- (void)showPreviousPhotoAnimated:(BOOL)animated;

@end
